/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CompanyExtManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.PhoneBoxUtil;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class VOIPAgentReport extends AbstractVOIPReport
/*    */ {
/* 28 */   private static Logger logger = Logger.getLogger(VOIPAgentReport.class
/* 29 */     .getName());
/*    */ 
/*    */   public VOIPAgentReport(AbstractHttpServlet servlet)
/*    */   {
/* 32 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 39 */     User user = super.getLoginUser(request);
/*    */ 
/* 41 */     if ((!user.isAdmin()) && (!user.isGroupAdmin())) {
/* 42 */       logger.warn("user not admin and group admin , userId: " + 
/* 43 */         user.userId);
/* 44 */       showErrorMessage(response, "只有管理员和部门管理员才有权限查看通话统计");
/* 45 */       return;
/*    */     }
/*    */ 
/* 48 */     CompanyExtManager companyExtManager = new CompanyExtManager();
/* 49 */     String companyId2 = companyExtManager.getFieldValue(user.companyId, 
/* 50 */       4);
/* 51 */     String password = companyExtManager.getFieldValue(user.companyId, 
/* 52 */       5);
/* 53 */     if ((companyId2 == null) || (companyId2.trim().length() == 0) || 
/* 54 */       (password == null) || (password.trim().length() == 0)) {
/* 55 */       logger.warn("not set companyId or passwrod");
/* 56 */       showErrorMessage(response, "系统设置中，没有设置呼叫中心账号和密码信息");
/* 57 */       return;
/*    */     }
/*    */ 
/* 60 */     response.setContentType("text/html;charset=utf-8");
/* 61 */     PrintWriter out = response.getWriter();
/*    */ 
/* 64 */     String searchDate = Util.getURLParameter(request
/* 65 */       .getParameter("searchDate"));
/* 66 */     int minTotalTime = Util.getURLIntParameter(request
/* 67 */       .getParameter("minTotalTime"));
/* 68 */     int maxTotalTime = Util.getURLIntParameter(request
/* 69 */       .getParameter("maxTotalTime"));
/*    */ 
/* 71 */     String startDate = "";
/* 72 */     String endDate = "";
/* 73 */     if ((searchDate != null) && (searchDate.trim().length() > 0)) {
/* 74 */       int idx = searchDate.indexOf("~");
/* 75 */       if (idx > 0) {
/* 76 */         startDate = searchDate.substring(0, idx).trim();
/* 77 */         endDate = searchDate.substring(idx + 1).trim();
/* 78 */       } else if (idx == 0) {
/* 79 */         endDate = searchDate.substring(idx + 1).trim();
/*    */       } else {
/* 81 */         startDate = searchDate;
/*    */       }
/*    */ 
/*    */     }
/*    */ 
/* 87 */     String body = PhoneBoxUtil.getSeatReport(companyId2, password, 
/* 88 */       minTotalTime, maxTotalTime, startDate, endDate);
/* 89 */     if ((body == null) || (body.trim().length() == 0)) {
/* 90 */       super.showErrorMessage(response, "获得统计信息失败，请稍后再试");
/* 91 */       return;
/*    */     }
/* 93 */     out.println(body);
/* 94 */     out.flush();
/* 95 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.VOIPAgentReport
 * JD-Core Version:    0.6.1
 */